<template>
  <div>
    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label=""><el-input size="small" v-model="formInline.kechengbianhao" placeholder="输入课程编号"></el-input></el-form-item>
      <el-form-item label=""><el-input size="small" v-model="formInline.kechengmingcheng" placeholder="输入课程名称"></el-input></el-form-item>

      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" @selection-change="handleSelectionChange">
      <el-table-column align="center" type="selection" width="60"></el-table-column>
      <el-table-column sortable prop="kechengbianhao" label="课程编号"></el-table-column>
      <el-table-column sortable prop="kechengmingcheng" label="课程名称"></el-table-column>
      <el-table-column sortable prop="xuefen" label="学分"></el-table-column>
      <el-table-column sortable prop="zongrenshu" label="总人数"></el-table-column>
      <el-table-column sortable prop="shengyurenshu" label="剩余人数"></el-table-column>
      <el-table-column sortable prop="gonghao" label="工号"></el-table-column>
      <el-table-column sortable prop="jiaoshixingming" label="教师姓名"></el-table-column>
      <el-table-column sortable prop="renshu" label="人数"></el-table-column>
<!--      <el-table-column sortable prop="yonghuming" label="用户名"></el-table-column>-->
<!--      <el-table-column sortable prop="xingming" label="姓名"></el-table-column>-->

      <el-table-column sortable prop="addtime" label="添加时间" width="160">
        <template slot-scope="scope">
          <div>{{scope.row.addtime|datePipe('yyyy-MM-dd hh:mm:ss')}}</div>
        </template>
      </el-table-column>

      <el-table-column align="center" label="操作" min-width="160">
        <template slot-scope="scope">
          <el-button size="mini"  type="danger" @click="addSalary(scope.$index, scope.row)">成绩添加</el-button>
        </template>
      </el-table-column>
    </el-table>
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>

  </div>
</template>

<script>
import Pagination from "@/layout/pagination/Pagination";
import { kechengxuanzeList, kechengxuanzeSave, kechengxuanzeDelete,kechengxuanzeEdit,kechengxuanzeDeleteList } from '@/api/kechengxuanze/kechengxuanzeApi';


import {Session} from "@/utils/storage";
export default {
  name: 'user',
  data() {
    return {
      loading: false, //是显示加载
      title: '',
      editFormVisible: false, //控制编辑页面显示与隐藏

      editForm: {
      },
      user:[],
      username:'',
      cx:'',

      rules: {

      },

      formInline: {
        page: 1,
        limit: 10,
      },


      listData: [],
      kechengxuanzes:[],
      checkmenu: [],
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      }
    };
  },
  computed:{
    headers(){
      return {"token":Session.get("token")}
    }
  },
  watch: {
    '$route' (to, from) {
      // 路由发生变化页面刷新
      this.$router.go(0);
    }
  },
  components: {
    Pagination
  },
  created() {
    this.getdata(this.formInline)
    if (!Session.get('userInfo')) return false;
    this.userInfo = Session.get('userInfo');
    this.username=localStorage.getItem("username");
    this.cx=localStorage.getItem("cx");

  },
  methods: {
    getdata(parameter) {
      kechengxuanzeList(parameter)
          .then(res => {
            this.loading = false
            if (res.success == false) {
              this.$message({
                type: 'info',
                message: res.msg
              })
            } else {
              this.listData = res.data.list

              // 分页赋值
              this.pageparm.currentPage = this.formInline.current
              this.pageparm.pageSize = this.formInline.currentNum
              this.pageparm.total = res.data.total
            }
          })
          .catch(err => {
            this.loading = false
            this.$message.error('菜单加载失败，请稍后再试！')
          })
    },
    //qixuzhijixsuan3
    // 分页插件事件
    callFather(parm) {
      this.formInline.current = parm.currentPage
      this.getdata(this.formInline)
    },
    //xia2sui1
    // 搜索事件
    search() {
      this.getdata(this.formInline)
    },
    //显示编辑界面

    addSalary(index,row){
      this.$router.push({
        name:'chengjitianjia_addlbdq',
        params:{
          id:row.id
        }
      })
    },
    // 编辑、增加页面保存方法

    // 删除公司






    // 关闭编辑、增加弹出框

  },
};
</script>

<style scoped lang="scss">
@import './index.scss';
</style>
